<template>
	<div style="margin-top:20px;">
		<van-cell title="选择单个日期" :value="date" @click="show = true" />
		<!-- <van-calendar v-model:show="show" @confirm="onConfirm" /> -->
		<van-calendar v-model:show="show" @click="sign()" />
	</div>
	<div style="margin-top:20px;">
		<van-button icon="plus" round @click="tzTrain"  type="primary">添加训练</van-button>
	</div>
	<div>
		
	</div>
</template>

<script>
	import { ref } from 'vue';
	
	export default {
	  setup() {
	    const date = ref('');
	    const show = ref(false);
	
	    const formatDate = (date) => `${date.getMonth() + 1}/${date.getDate()}`;
	    const onConfirm = (value) => {
	      show.value = false;
	      date.value = formatDate(value);
	    };
	    return {
	      date,
	      show,
	      onConfirm,
	    };
	  },
	  methods:{
	  	tzTrain(){
	  		this.$router.push("/train");
	  	},
		sign(){
			this.axios.get("/usersign/sign").then((res) => {
						 if(res.data.code==200){
							 //可用
							this.$toast.success('签到成功');
							this.show = false;
						 }else{
							 //存在，不可用
							 this.$toast.fail('签到失败');
							 this.show = false;
						 }
			});
		}
	  }
	};
</script>

<style>
	
</style>
